#include "udp_server.hpp"
#include <memory>

using namespace cwq_server;
using namespace std;


static void Usage(string proc)  //使用提示
{
    cout<<"\nUsage:\n\t"<<proc<<" local_port\n\n";
}
std::string transactionString(std::string request) // request 就是一个string
{  //大小写转化业务
    std::string result;
    char c;
    for (auto &r : request)
    {
        if (islower(r))
        {
            c = toupper(r);
            result.push_back(c);
        }
        else
        {
            result.push_back(r);
        }
    }

    return result;
}



int main(int argc,char* argv[])
{
    if(argc !=2){
        Usage(argv[0]);
        exit(USAGE_ERR);
    }
    uint16_t port=atoi(argv[1]);
    //unique_ptr<udpServer> usvr(new udpServer("127.0.0.1", 8082));
    //unique_ptr<udpServer> usvr(new udpServer(port));
    //unique_ptr<udpServer> usvr(new udpServer(transactionString,port));
     unique_ptr<udpServer> usvr(new udpServer(port));

    usvr->InitServer(); //服务器的初始化
    usvr->Start();

    return 0;
}